package com.thientan.model

import com.thientan.utils.Constants

/**
 * Domain class used to represent entity from table THONG_KE.
 * @author DINH HONG CHAU
 *
 */
class ThongKe {
	static mapping = {
		table 'THONG_KE'
		id generator : 'increment'
		columns { id column : 'THONG_KE_ID' }
	}

	static transients = ['ngayLapText']

	String getNgayLapText() {
		new java.text.SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT).format(ngayLap)
	}

	Date ngayLap = new Date()
	Long tongSoHd
	Long tongSoHdThuTienNgay
	Long tongSoHdDangGop
	Long tongSoHdTraHang
	Long tongSoHdDenHang
	Long tongSoHdKhoThu
	Long tongSoHdKetThuc
	Double tongDoanhThuLyThuyet
	Double tongGiamGia
	Double tongDenHangCtyChiu
	Double tongDenHangNvDt
	Double tongKhoThuCtyChiu
	Double tongChiPhiTraHang
	Double tongKhauHao
	Double tongDoanhThuThucTe
	Double tongDaThu
	Double tongPhaiThu

	void updateDoanhThuThucTe() {
		tongDoanhThuThucTe = (tongDoanhThuLyThuyet + tongKhauHao) - 
		   				   (tongGiamGia + tongDenHangCtyChiu + tongDenHangNvDt + tongKhoThuCtyChiu + tongChiPhiTraHang)
		tongPhaiThu = tongDoanhThuThucTe - tongDaThu
	}
}
